/**
 * 
 */
package com.csair.youth.dao.query.impl;

import java.util.Map;

import com.csair.youth.database.Category;
import com.csair.youth.database.Permission;
import com.csair.youth.database.Resource;
import com.csair.youth.database.User;

import common.query.Query;
import common.query.QueryUtils;

/**
 * @author mickey
 *
 */
public class ResourceQueryDaoImpl extends BaseQueryDao {

	/* (non-Javadoc)
	 * @see com.csair.youth.dao.query.impl.BaseQueryDao#createQuery(java.util.Map)
	 */
	@Override
	protected Query createQuery(Map map) {
		// TODO Auto-generated method stub
		StringBuffer buf = new StringBuffer();
		buf.append(" from " + Resource.REF + " a, "+User.REF+" b, "+Category.REF+" c ");
		buf.append(" where 1=1 and a."+Resource.PROP_UPLOAD_USER_ID+"=b."+User.PROP_ID+" and a."+Resource.PROP_CATEGORY_ID+"=c."+Category.PROP_ID);
		buf.append("  /~ and a." + Resource.PROP_FILE_NAME + " like {fileName?string_fl} ~/");
		buf.append("  /~ and b." + User.PROP_NAME + " like {uploadUserName?string_fl} ~/");
		buf.append("  /~ and a." + Resource.PROP_AUDIT_RESULT + " = {auditResult} ~/");
		buf.append("  /~ and c." + Category.PROP_ID + " = {categoryId} ~/");
		Query query = QueryUtils.filterQuery(buf.toString(), map);
		return query;
	}

	/* (non-Javadoc)
	 * @see com.csair.youth.dao.query.impl.BaseQueryDao#createSelect(java.lang.String)
	 */
	@Override
	protected String createSelect(String temp) {
		return "select a."+Resource.PROP_ID+", a."+Resource.PROP_FILE_NAME+", c."+Category.PROP_NAME+", b."+User.PROP_NAME+", a."+Resource.PROP_UPLOAD_IP+", a."+Resource.PROP_AUDIT_RESULT+", a."+Resource.PROP_DOWNLOAD_TIMES+", a."+Resource.PROP_UPLOAD_TIME+" " +temp;
	}

}
